﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FoneBuddy.LinqModel;
using FoneBuddy.LinqModel.Data;
using FoneBuddy.LinqData;

public partial class Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        test3 t3=new test3();
        string s1 = t3.method1();

        test2 t2 = new test2();
        string s2 = t2.method1("6");

        test1 t1 = new test1();
        string s3 = t1.method1("5");
    }
    #region Filter
    //public void CreateFilter(FilterMaster filter)
    //{
    //    _dbFoneBuddy.Filters.InsertOnSubmit(filter);
    //    _dbFoneBuddy.SubmitChanges();
    //}
    //public List<FilterMaster> GetAllFilter()
    //{
    //    var result = (from c in _dbFoneBuddy.Filters where c.IsDeleted == false select c).ToList();
    //    return result;
    //}
    //public void DeleteFilter(FilterMaster filter)
    //{
    //    FilterMaster deleteObj = (from u in _dbFoneBuddy.Filters
    //                        where u.Id.Equals(filter.Id)
    //                        select u).SingleOrDefault();
    //    if (deleteObj != null)
    //    {

    //        _dbFoneBuddy.Filters.DeleteOnSubmit(deleteObj);
    //        _dbFoneBuddy.SubmitChanges();
    //    }
    //}
    //public void GetFilterById(FilterMaster filter)
    //{
    //    var result = (from b in _dbFoneBuddy.Filters
    //                  where b.Id.Equals(filter.Id) && b.IsDeleted == false
    //                  select b).First();
    //    if (result != null)
    //        PopulateModel(result, filter);
    //}
    //public void UpdateFilter(FilterMaster filter)
    //{
    //    var result = _dbFoneBuddy.Filters.Where(x => x.Id == filter.Id).FirstOrDefault();
    //    if (result != null)
    //    {
    //        result.Name = filter.Name;
    //        result.UpdatedDate = filter.UpdatedDate;

    //    }
    //    _dbFoneBuddy.SubmitChanges();

    //}
    //public void GetFilterByName(FilterMaster filter)
    //{
    //    var result = (from b in _dbFoneBuddy.Filters
    //                  where b.Name.Equals(filter.Name) && b.IsDeleted == false
    //                  select b).FirstOrDefault();
    //    if (result != null)
    //        PopulateModel(result, filter);

    //}
    #endregion
    public class test1
    {
        public string publicstring;
        private string privatestring="class1";
        protected string protectedstring;
        public virtual string method1(string f)
        {
            return "First class";
        }
        public static int Plus(int number1, int number2)
        {
            //return Plus(number1, number2, 0);
            return 5;
        }
        public static float Plus(int number1, int number2, int number3)
        {
            return number1 + number2 + number3;
        }
    }
    public class test2 : test1
    {
        protected string protectedstring="class2";
        public string publicstring2;
        protected string protectedstring2 = "class3";
        //public   string method1()
        //{
        //    test1 t = new test1();
          
        ////    string s = "";
        //    return "2 class";
        //}
        public override string method1(string s)
        {
            return "second class";
        }
    }
    //    service Orientation is one of the key advantages of WCF. We can easily build service-oriented applications using WCF.
    //If compared with ASMX web services, WCF service provides reliability and security with simplicity.
    //As oppose to .NET Remoting, WCF services are interoperable.
    //Different clients can interact with same service using different communication mechanism.
    //This is achieved by using service endpoints.
    //A single WCF service can have multiple endpoints. So, developer will write code for service once and just by changing configuration (defining another service endpoint), it will be available for other clients as well.
    //Extensibility is another key advantage of WCF.  We can easily customize a service
    //behavior if required.
    //What are the core components of WCF Service?
    //A WCF service has at least following core components.
    //Service Class:  A ervice class implementing in any CLR-based language and expose at least one method.
    //Hosting Environment: a managed process for running service.
    //Endpoint: a client uses it to communicate with service.
    //What is the difference between WCF and ASMX Web services?

    //The basic difference is that ASMX web service is designed to send and receive messages using SOAP over HTTP
    //only. While WCF service can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, Named Pipes etc).
    //You can find detailed discussion on WCF Vs ASMX Web services here.

    //different contract
//1)service contract
//A service contract defines the operations which are exposed by the service to the outside world.

//2)Operation contract
//An operation contract is defined within a service contract. It defines the parameters and return type of an operation. 

//3)datacontract
//A data contract defines the data type of the information that will be exchange be-tween the client and the service.

//4)MessageCOntract
//When an operation contract required to pass a message as a parameter or return value as a message, the type of this message will be defined as message contract.


//5)fault contract
//A fault contract defines errors raised by the service, and how the service handles and propagates errors to its clients


    public class test3 : test2
    {
        test2 t2 = new test2();
        
         
        public string method1()
        {
            
            string s = protectedstring;
            
            return "3 class";
        }
    }
    [System.Web.Services.WebMethod]
    public static string[] LoadInfo(Int32 Id)
    {
        Id = 9;
        string[] a = new string[14];
        IDataRepository _dataObject = new DataRepository();
        Merchant merchant = new Merchant(_dataObject);
        merchant.Id = Id;
        merchant.GetMerchantById();

        //lblBusinessName.InnerText = merchant.BusinessName;
        //lblLastLoginDate.Text = merchant.LastLoginDate.ToString();
        //lblEmailId.Text = merchant.Email;
        a[0] = merchant.BusinessName;
        a[1] = merchant.LastLoginDate.ToString();
        a[2] = merchant.Email;


        Address address = new Address(_dataObject);
        address.MerchantId = Id;
        List<Address> addresses = address.GetAddressByMerchantId();
        a[3] = addresses.ElementAt(0).Address1;
        a[4] = addresses.ElementAt(0).Address2;
        a[5] = addresses.ElementAt(0).City.Name;
        a[6] = addresses.ElementAt(0).Pincode;
        //rptAddress.DataSource = addresses;
        //rptAddress.DataBind();

        SubscriptionHistory subHistory = new SubscriptionHistory(_dataObject);
        List<SubscriptionHistory> subHistories = new List<SubscriptionHistory>();
        subHistory.MerchantId = Id;
        subHistories = subHistory.GetSubscriptionHistoryByMerchantId();
        //lblSubscription.Text = subHistories.ElementAt(0).Subscription.PlanName;
        //lblStartDate.Text = subHistories.ElementAt(0).StartDate.ToString("dd/MM/yyyy");
        //lblOldExpiryDate.Text = subHistories.ElementAt(0).ExpiryDate.ToString("dd/MM/yyyy");
        //lblDuration.Text = subHistories.ElementAt(0).Subscription.Duration + " Month";
        a[7] = subHistories.ElementAt(0).Subscription.PlanName; ;
        a[8] = subHistories.ElementAt(0).StartDate.ToString("dd/MM/yyyy");
        a[9] = subHistories.ElementAt(0).ExpiryDate.ToString("dd/MM/yyyy");
        a[10] = subHistories.ElementAt(0).Subscription.Duration + " Month";
        a[11] = merchant.LastLoginDate.ToString();
        a[12] = merchant.Name;
        a[13] = merchant.Mobile;

        return a;

    }
    
}